package jmine.tec.web.wicket.mock;

import java.io.IOException;
import java.util.Locale;
import java.util.Map;

import javax.servlet.ServletContext;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.core.io.Resource;
import org.springframework.web.context.WebApplicationContext;

/**
 * MockWebApplicationContext
 * 
 * @author Rafael Volpato
 * @date Oct 5, 2011
 */
public class MockWebApplicationContext implements WebApplicationContext {

    private final ApplicationContext delegate;

    private final ServletContext servletContext;

    /**
     * Construtor.
     * 
     * @param applicationContext {@link ApplicationContext}
     * @param servletContext {@link ServletContext}
     */
    public MockWebApplicationContext(ApplicationContext applicationContext, ServletContext servletContext) {
        this.delegate = applicationContext;
        this.servletContext = servletContext;
    }

    /**
     * {@inheritDoc}
     */
    public ServletContext getServletContext() {
        return this.servletContext;
    }

    /**
     * {@inheritDoc}
     */
    public void publishEvent(ApplicationEvent event) {
        this.delegate.publishEvent(event);
    }

    /**
     * {@inheritDoc}
     */
    public BeanFactory getParentBeanFactory() {
        return this.delegate.getParentBeanFactory();
    }

    /**
     * {@inheritDoc}
     */
    public boolean containsLocalBean(String name) {
        return this.delegate.containsLocalBean(name);
    }

    /**
     * {@inheritDoc}
     */
    public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
        return this.delegate.getMessage(code, args, defaultMessage, locale);
    }

    /**
     * {@inheritDoc}
     */
    public Resource getResource(String location) {
        return this.delegate.getResource(location);
    }

    /**
     * {@inheritDoc}
     */
    public String getMessage(String code, Object[] args, Locale locale) {
        return this.delegate.getMessage(code, args, locale);
    }

    /**
     * {@inheritDoc}
     */
    public boolean containsBeanDefinition(String beanName) {
        return this.delegate.containsBeanDefinition(beanName);
    }

    /**
     * {@inheritDoc}
     */
    public String getId() {
        return this.delegate.getId();
    }

    /**
     * {@inheritDoc}
     */
    public ClassLoader getClassLoader() {
        return this.delegate.getClassLoader();
    }

    /**
     * {@inheritDoc}
     */
    public Resource[] getResources(String locationPattern) throws IOException {
        return this.delegate.getResources(locationPattern);
    }

    /**
     * {@inheritDoc}
     */
    public String getDisplayName() {
        return this.delegate.getDisplayName();
    }

    /**
     * {@inheritDoc}
     */
    public String getMessage(MessageSourceResolvable resolvable, Locale locale) {
        return this.delegate.getMessage(resolvable, locale);
    }

    /**
     * {@inheritDoc}
     */
    public long getStartupDate() {
        return this.delegate.getStartupDate();
    }

    /**
     * {@inheritDoc}
     */
    public int getBeanDefinitionCount() {
        return this.delegate.getBeanDefinitionCount();
    }

    /**
     * {@inheritDoc}
     */
    public ApplicationContext getParent() {
        return this.delegate.getParent();
    }

    /**
     * {@inheritDoc}
     */
    public String[] getBeanDefinitionNames() {
        return this.delegate.getBeanDefinitionNames();
    }

    /**
     * {@inheritDoc}
     */
    public AutowireCapableBeanFactory getAutowireCapableBeanFactory() {
        return this.delegate.getAutowireCapableBeanFactory();
    }

    /**
     * {@inheritDoc}
     */
    public String[] getBeanNamesForType(Class type) {
        return this.delegate.getBeanNamesForType(type);
    }

    /**
     * {@inheritDoc}
     */
    public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit) {
        return this.delegate.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
    }

    /**
     * {@inheritDoc}
     */
    public Object getBean(String name) {
        return this.delegate.getBean(name);
    }

    /**
     * {@inheritDoc}
     */
    public Object getBean(String name, Class requiredType) {
        return this.delegate.getBean(name, requiredType);
    }

    /**
     * {@inheritDoc}
     */
    public Map getBeansOfType(Class type) {
        return this.delegate.getBeansOfType(type);
    }

    /**
     * {@inheritDoc}
     */
    public Object getBean(String name, Object[] args) {
        return this.delegate.getBean(name, args);
    }

    /**
     * {@inheritDoc}
     */
    public boolean containsBean(String name) {
        return this.delegate.containsBean(name);
    }

    /**
     * {@inheritDoc}
     */
    public Map getBeansOfType(Class type, boolean includeNonSingletons, boolean allowEagerInit) {
        return this.delegate.getBeansOfType(type, includeNonSingletons, allowEagerInit);
    }

    /**
     * {@inheritDoc}
     */
    public boolean isSingleton(String name) {
        return this.delegate.isSingleton(name);
    }

    /**
     * {@inheritDoc}
     */
    public boolean isPrototype(String name) {
        return this.delegate.isPrototype(name);
    }

    /**
     * {@inheritDoc}
     */
    public boolean isTypeMatch(String name, Class targetType) {
        return this.delegate.isTypeMatch(name, targetType);
    }

    /**
     * {@inheritDoc}
     */
    public Class getType(String name) {
        return this.delegate.getType(name);
    }

    /**
     * {@inheritDoc}
     */
    public String[] getAliases(String name) {
        return this.delegate.getAliases(name);
    }

}
